<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/11/20
 * Time: 10:05
 */

use yii\widgets\ActiveForm;
use doumiaoduo\layer\LayerAsset;
LayerAsset::register($this);
?>

<?php $form = ActiveForm::begin(['enableAjaxValidation' => false,'enableClientValidation' => true,'options'=>['class'=>'form-validate']]); ?>
<table width="100%" class="table-form">
    <tr>
        <th class="zx-goods-table" style="width: 30%">可调课次数</th>
        <td><?=$surplusLesson?>节</td>
    </tr>
    <tr>
        <th class="zx-goods-table" style="width: 30%">选择调入班级</th>
        <td style="display: inline-block;width: 206px"><?= $form->field($model, 'new_class_manage_id', ['template' => '{input}{error}{hint}'])->widget(\kartik\select2\Select2::className(),['data'=>$inclassList,'options' => ['placeholder' => '请选择']]) ?></td>

    </tr>
    <tr>
        <th class="zx-goods-table" style="width: 30%">选择从那节调</th>
        <td><?= $form->field($model, 'lesson', ['template' => '{input}{error}{hint}'])->dropDownList([], ['prompt' => '请选择','style' => 'width:180px']) ?></td>
    </tr>
    <tr>
        <th class="zx-goods-table" style="width: 30%">调班原因</th>
        <td><?= $form->field($model, 'content', ['template' => '{input}{error}{hint}'])->textarea() ?></td>
    </tr>
</table>
<div class="m_top_10 btn" style="display: none">
    <?= \yii\helpers\Html::submitButton('提交', ['class' => "button", 'id' => 'dosubmit']) ?>
</div>
<?php ActiveForm::end(); ?>
<?php
$js = <<<JS
    layer.config({
            extend: ['skin/customskin/style.css']//加载您的扩展样式
        });

   $(document).on('change','#classmanageturn-new_class_manage_id',function() {
       var id = $(this).val();
       var url = $('#w0').attr('action');
       if(id.length > 0){
           $.ajax({
                 url:url,
                 type:'post',
                 data:{newclass_id: id,ajax:'newclass',_csrf:yii.getCsrfToken()},
                 dataType:'json',
                 beforeSend:function(){
                    layer.load(0, { shade: [0.5, '#393D49'] });
                 },
                 complete:function(){
                  layer.close(layer.load(0, { shade: [0.5, '#393D49'] }));  
                },
                success:function(data){
                     if(data.status == 1){
                         if(data.lessonList.length > 0){
                             var str = '';
                             for (var i=0;i<data.lessonList.length;i++){
                                 var lesson = data.lessonList[i];
                                 str += '<option value="'+lesson.lesson_id+'">第'+lesson.lesson+'节</option>';
                             }
                         }
                         $('#classmanageturn-lesson').html(str);
                     }else{
                          layer.msg(data.content,{id:'layer-msg',skin: 'layui-msg-customskin',time: 2000});
                          return false;
                     }
                }
             });
       }
   });
JS;
$this->registerJS($js);
?>
